package net.sk.china.city.controller;

import net.sk.china.city.domain.vo.AddDonate;
import net.sk.china.city.domain.vo.UpdateDonateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import net.sk.china.city.controller.base.BaseController;
import net.sk.china.city.domain.dto.AjaxResult;
import net.sk.china.city.domain.ArDonate;
import net.sk.china.city.service.IArDonateService;
import net.sk.china.city.domain.dto.TableDataInfo;

/**
 * 捐赠列表Controller
 * 
 * @author gxf
 * @date 2024-04-07
 */
@Api(tags = "捐赠列表")
@RequiredArgsConstructor
@RestController
@RequestMapping("/donate/donate")
public class ArDonateController extends BaseController
{
    @Autowired
    private IArDonateService arDonateService;

    /**
     * 查询捐赠列表列表
     */
    @ApiOperation("捐赠列表")
    @PreAuthorize("hasAnyAuthority('donate:donate:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArDonate arDonate)
    {
        startPage();
        return arDonateService.selectArDonateList(arDonate);
//        return getDataTable(list);
    }

    /**
     * 导出捐赠列表列表
     */
//    @PreAuthorize("@ss.hasPermi('donate:donate:export')")
//    @Log(title = "捐赠列表", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ArDonate arDonate)
//    {
//        List<ArDonate> list = arDonateService.selectArDonateList(arDonate);
//        ExcelUtil<ArDonate> util = new ExcelUtil<ArDonate>(ArDonate.class);
//        util.exportExcel(response, list, "捐赠列表数据");
//    }

    /**
     * 获取捐赠列表详细信息
     */
    @ApiOperation("捐赠详情")
    @PreAuthorize("hasAnyAuthority('donate:donate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(arDonateService.selectArDonateById(id));
    }

    /**
     * 新增捐赠列表
     */
    @ApiOperation("新增捐赠")
    @PreAuthorize("hasAnyAuthority('donate:donate:add')")
    @PostMapping
    public AjaxResult add(@RequestBody AddDonate addDonate)
    {
        return toAjax(arDonateService.insertArDonate(addDonate));
    }

    /**
     * 修改捐赠列表
     */
    @ApiOperation("修改捐赠")
    @PreAuthorize("hasAnyAuthority('donate:donate:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody UpdateDonateVO updateDonateVO)
    {
        return toAjax(arDonateService.updateArDonate(updateDonateVO));
    }

    /**
     * 删除捐赠列表
     */
    @ApiOperation("删除捐赠")
    @PreAuthorize("hasAnyAuthority('donate:donate:remove')")
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long[] id)
    {
        return toAjax(arDonateService.deleteArDonateByIds(id));
    }
}
